//
//  health
//
//  Created by apple on 2021/11/9.
//  Copyright © 2021 zglee. All rights reserved.
//

#import "MJDataBaseModel.h"

@implementation MJDataBaseModel

- (void)encodeWithCoder:(NSCoder *)aCoder {
    [self yy_modelEncodeWithCoder:aCoder];
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];
    return [self yy_modelInitWithCoder:aDecoder];
}

//- (void)encodeWithCoder:(NSCoder *)aCoder{
//    unsigned  int count = 0;
//    Ivar *ivars = class_copyIvarList(self.class, &count);
//    for (int i = 0; i < count; i++) {
//        const char *cname = ivar_getName(ivars[i]);
//        NSString *name = [NSString stringWithUTF8String:cname];
//        NSString *key = [name substringFromIndex:1];
//        id value = [self valueForKey:key];
////        if([value isKindOfClass:[NSNumber class]]){ //存在bool 值报错
////
////        }
//        [aCoder encodeObject:value forKey:key];
//    }
//}
//
//- (nullable instancetype)initWithCoder:(NSCoder *)aDecoder{
//    if (self = [super init]) {
//        unsigned  int count = 0;
//        Ivar *ivars = class_copyIvarList(self.class, &count);
//        for (int i = 0; i < count; i++) {
//            const char *cname = ivar_getName(ivars[i]);
//            NSString *name = [NSString stringWithUTF8String:cname];
//            NSString *key = [name substringFromIndex:1];
//            id value = [aDecoder decodeObjectForKey:key];
//            [self setValue:value forKey:key];
//        }
//    }
//    return self;
//}

+ (BOOL)supportsSecureCoding {
    return YES;
}

@end
